﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

using FreeFlow.Administration;
using FreeFlow.WinFormsControls.HelperClasses;

namespace FreeFlowAdministrator
{
  public partial class WorkflowControl : AdminUserControl
  {
    public WorkflowControl()
    {
      InitializeComponent();

      UIActionList actions = new UIActionList();
      actions.Add("Delete", "Delete this workflow", new ActionExecuteDelegate(DeleteWorkflow));
      uiActionsControl.Actions = actions;
    }

    private Workflow workflow;
    public void LoadWorkflow(Workflow workflow)
    {
      this.workflow = workflow;
      nameLabel.Text = workflow.Name;
      guidLabel.Text = workflow.Guid.ToString();
    }

    private string DeleteWorkflow()
    {
      if (MessageBox.Show("Delete this workflow?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
      {
        using (new CursorHandler())
        {
          workflow.Delete();
        }
        OnItemDeleted();
        Dispose();
      }
      return null;
    }
  }
}
